package com.zhangmeng.tools.utils;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;

import java.nio.charset.Charset;
import java.util.Map;

/**
 * @author : 芊芊墨客
 * @version : 1.0
 * @date : 2023-03-08 10:41
 */
@Slf4j
public class HttpUtils {

    public static String get_request(String url){
        return HttpRequest.get(url).execute().body();
    }
    public static String get_request(String url, Map<String,Object> paramMap){
        return HttpRequest.get(url).form(paramMap).execute().body();
    }
    public static String get_request(String url,Map<String,Object> paramMap, Charset charset){
        return HttpRequest.get(url).form(paramMap).charset(charset).execute().body();
    }

    public static String get_request(String url,Map<String,Object> paramMap, Charset charset,int milliseconds ){
        return HttpRequest.get(url).form(paramMap).charset(charset).timeout(milliseconds).execute().body();
    }

    public static String post_request(String url,Map<String,Object> paramMap){
        return HttpUtil.post(url, paramMap);
    }

}
